package com.shenhan.assistclass;

import java.util.concurrent.CountDownLatch;
import java.util.stream.IntStream;

/**
 * @Author shenhan
 * @Date: 2020/6/10 21:52
 * @Description:
 */
public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        IntStream.range(1, 7).forEach(i -> {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + " Go Out!");
                countDownLatch.countDown();
            }, String.valueOf(i)).start();
        });

        countDownLatch.await();
        System.out.println("Close Door!");
    }
}
